package com.hyz.listener.assetManager;

import com.alibaba.fastjson.JSON;
import com.hyz.service.assetManager.AssetManagerService;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import pojo.permission.assetManager.AssetImportRequest;


/**
 * @author HGD
 * @date 2022/9/30 12:53
 */
@Component
public class AssetManagerListener {
    @Autowired
    private AssetManagerService service;

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(name = "assetImport.queue"),
            exchange = @Exchange(name = "assetManager", type = ExchangeTypes.DIRECT),
            key = {"createAssetImport"}
    ))
    public void createAssetImport(String massage) {
        AssetImportRequest request = JSON.parseObject(massage, AssetImportRequest.class);
        service.createAssetImport(request);
    }
}
